]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
shell/app: Plug GTask leak
authorAlessandro Bono <alessandro.bono369@gmail.com>
Fri, 19 Jun 2026 10:43:31 +0000 (12:43 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Mon, 29 Jun 2026 17:48:28 +0000 (19:48 +0200)
The shell_app_activate_action() function gives ownership of the task
to activate_action_get_bus_cb(), which then transfers it to
on_activate_action_cb().

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/4258>
(cherry picked from commit 8e7c0290ef7b0846bf4953217b0e2241d1259811)

src/shell-app.c

index 9b5ccdfc18bdbbac37c76ee7804bac01eac17437..5864a6c8ae75450afae88fa439ea2717fb905b36 100644 (file)
@@ -1504,7 +1504,7 @@ on_activate_action_cb (GObject      *source,
                        GAsyncResult *res,
                        gpointer      user_data)
 {
-  GTask *task = G_TASK (user_data);
+  g_autoptr (GTask) task = G_TASK (user_data);
   g_autoptr (GVariant) value = NULL;
   g_autoptr (GError) error = NULL;
 
@@ -1522,12 +1522,14 @@ activate_action_get_bus_cb (GObject      *object,
                             GAsyncResult *result,
                             gpointer      user_data)
 {
-  GTask *task = G_TASK (user_data);
+  g_autoptr (GTask) task = G_TASK (user_data);
   ShellApp *app = NULL;
   g_autoptr (GDBusConnection) session_bus = NULL;
   g_autoptr (GError) error = NULL;
   g_autofree gchar *object_path = NULL;
   g_autofree gchar *app_id = NULL;
+  GVariant *task_data = NULL;
+  GCancellable *cancellable = NULL;
   gchar *last_dot;
 
   session_bus = g_bus_get_finish (result, &error);
@@ -1546,14 +1548,16 @@ activate_action_get_bus_cb (GObject      *object,
       *last_dot = '\0';
 
   object_path = object_path_from_app_id (app_id);
+  task_data = g_task_get_task_data (task);
+  cancellable = g_task_get_cancellable (task);
 
   g_dbus_connection_call (session_bus,
                           app_id, object_path,
                           "org.freedesktop.Application", "ActivateAction",
-                          g_task_get_task_data (task),
+                          task_data,
                           NULL, G_DBUS_CALL_FLAGS_NONE, -1,
-                          g_task_get_cancellable (task),
-                          on_activate_action_cb, task);
+                          cancellable,
+                          on_activate_action_cb, g_steal_pointer (&task));
 }